package com.glsc.ngateway.platform.controller.glres;


import com.glsc.ngateway.common.api.platform.resp.PlatformResponse;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.glres.GlscSystemPartner;
import com.glsc.ngateway.platform.aspect.UserCache;
import com.glsc.ngateway.platform.dto.GlscSystemPartnerDto;
import com.glsc.ngateway.platform.service.glres.GlscSystemPartnerService;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * 资源管理-系统对接信息管理
 */
@RestController
@RequestMapping("/api/res/system/partner")
@Slf4j
public class GlscSystemPartnerController {

    @Resource
    private UserCache userCache;

    @Resource
    private GlscSystemPartnerService glscSystemPartnerService;

    /**
     * 分页查找
     *
     * @param dto
     * @param request
     * @return
     */
    @PostMapping("/page")
    public PlatformResponse<Page<GlscSystemPartner>> page(@RequestBody GlscSystemPartnerDto dto, HttpServletRequest request) {

        Page<GlscSystemPartner> page = glscSystemPartnerService.page(dto);
        return PlatformResponse.successData(page);
    }

    /**
     * 根据id查找
     *
     * @param
     * @return
     */
    @GetMapping("/findById")
    public PlatformResponse<GlscSystemPartner> findById(@ApiParam(required = false, value = "id") @RequestParam(required = true) Integer id) {
        return PlatformResponse.successData(glscSystemPartnerService.findById(id));
    }

    /**
     * 保存
     *
     * @param obj
     * @return
     */
    @PostMapping("/save")
    public PlatformResponse<?> save(@RequestBody GlscSystemPartner obj) {
        glscSystemPartnerService.save(obj);
        return PlatformResponse.success();
    }

    /**
     * 根据地删除
     *
     * @param obj
     * @return
     */
    @PostMapping("/delete")
    public PlatformResponse<?> delete(@RequestBody GlscSystemPartner obj) {
        glscSystemPartnerService.delete(obj.getId());
        return PlatformResponse.success();
    }


}
